package com.xizi.秋招笔试;

/**
 * @author xizizzz
 * @description: TODO
 * @date 2021-8-15下午 07:35
 */
public class Test1 {
    public static void main(String[] args) {
        int a = changeNumber(1);
        System.out.println(a);
    }

    static int changeNumber(int num) {
        int temp = num;
        int count = 0;
        int count2 = 0;
        while (num != 0) {

            if ((num & 1) == 0) {
                count++;
            }
            if (count == 2) {
                int res = 1;
                for (int i = 0; i < count2; i++) {
                    res *= 2;
                }
                res += temp;
                if (res >= Integer.MAX_VALUE) {
                    return Integer.MAX_VALUE;
                }
                return temp + res;
            }
            num = num >> 1;
            count2++;
        }
        return temp;
    }
}
